function xhrHttpRequest(method, url, data, headerConfig) {
    return new Promise((resolve, reject) => {
        const xhr = new XMLHttpRequest();
        xhr.open(method, url, true);
        xhr.setRequestHeader("Content-type", "application/json");
        if (headerConfig) {
            for(let key in headerConfig) {
                xhr.setRequestHeader(key, headerConfig[key]);
            }
        }
        xhr.onreadystatechange = function () {
          if (xhr.readyState === 4) {
            const resData = xhr.response;
            if (xhr.status === 200) {
                resolve(resData);
            } else {
                reject(resData);
            }
          }
        };
        xhr.send(data);
    });
}
